using System;
using System.Collections.Generic;
using System.Text;

namespace BookInfoCS
{
    class BookInfoDesigner : System.Web.UI.Design.ControlDesigner
    {
        private string _Description;
        public override string GetDesignTimeHtml()        
        {
         string strDesignHTML;
         try
         { 
          //...code to generate custom HTML
             strDesignHTML = base.GetDesignTimeHtml();
         }
         catch(Exception ex)
         {
          strDesignHTML = GetErrorDesignTimeHtml(ex);
         }

         if(strDesignHTML == null)
         {

          strDesignHTML = GetEmptyDesignTimeHtml();
         }
         else
         {
          if(strDesignHTML.Length == 0)
          {
           strDesignHTML = GetEmptyDesignTimeHtml();
          }
          else
          {
              BookInfo bi;      
              
              bi = (BookInfo)this.Component;

              if (bi.Description.CompareTo("") > 0 )
              {
                  _Description = bi.Description;
                  strDesignHTML = "<b>Tag Content</b> <br/> " + "&lt;Description>" +
                                  _Description + " &lt;/Description>";
              }
            }
          }
         return strDesignHTML;
        }
        public override System.ComponentModel.Design.DesignerVerbCollection Verbs
        {
         get
         {
          System.ComponentModel.Design.DesignerVerbCollection vrbs = new 
             System.ComponentModel.Design.DesignerVerbCollection();
          System.ComponentModel.Design.DesignerVerb vrb = new 
             System.ComponentModel.Design.DesignerVerb ("Set Description", GetDescription);
          vrbs.Add(vrb);
          return vrbs;
         }
        }
        public void GetDescription(object sender, System.EventArgs e)
        {
            _Description = Microsoft.VisualBasic.Interaction.InputBox("Enter Description", "Description", _Description,0,0);
            this.UpdateDesignTimeHtml();
        }
        public override string GetPersistenceContent()
        {
            return "<Description>" + _Description + "</Description>";
        }
        protected override string GetEmptyDesignTimeHtml()
        {
            return this.CreatePlaceHolderDesignTimeHtml("<B> No content to display </B>");
        }

        protected override string GetErrorDesignTimeHtml(System.Exception e)
        {
            return this.CreateErrorDesignTimeHtml(e.Message);
        }

    }
}
